﻿using Architecture.API.Application.Command.RoleCommand;
using Architecture.Domain.Service.RoleServices;
using MediatR;

namespace Architecture.API.Application.CommandHandlers.RoleHandler
{
    /// <summary>
    /// 角色反向填充命令处理器
    /// </summary>
    public class RoleReverseFillingCommandHandler : IRequestHandler<RoleReverseFillingCommand, object>
    {
        /// <summary>
        /// 角色数据服务
        /// </summary>
        private readonly IRoleService _roleService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="roleService">角色数据服务</param>
        public RoleReverseFillingCommandHandler(IRoleService roleService)
        {
            _roleService = roleService;
        }

        /// <summary>
        /// 处理角色反向填充命令
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消标记</param>
        /// <returns>返回角色信息</returns>
        public async Task<object> Handle(RoleReverseFillingCommand request, CancellationToken cancellationToken)
        {
            return await _roleService.GetModel(request.RoleId);
        }
    }
}
